// pages/cabinetImgs/detail.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 组件参数设置，传递到组件
    defaultData: {
      title: "柜体相册", // 导航栏标题
      showHome: false, //是否显示回到首页按钮
      showBack: true, //是否显示返回按钮
      showLogo: false, //是否显示logo
      showViewBox: true,
      bgColor: 'transparent'
    },
    baseUrl: app.baseUrl,
    cabinetIndex: 0,
    cabinet: '玄关柜',
    cabinetList: [
      [{
        id: 0,
        name: '玄关柜'
      }, {
        id: 1,
        name: '客厅电视柜'
      }, {
        id: 2,
        name: '西厨岛台柜'
      }, {
        id: 3,
        name: '西厨橱柜'
      }, {
        id: 4,
        name: '西厨橱柜（左）'
      }, {
        id: 5,
        name: '西厨橱柜（右）'
      }, {
        id: 6,
        name: '中厨储物柜'
      }, {
        id: 7,
        name: '中厨橱柜'
      }, {
        id: 8,
        name: '中厨橱柜（左）'
      }, {
        id: 9,
        name: '主卧床头柜'
      }, {
        id: 10,
        name: '老人房卫生间镜柜'
      }, {
        id: 11,
        name: '客卫镜柜'
      }, {
        id: 12,
        name: '主卫镜柜'
      }],
      [{
        id: 0,
        name: '玄关柜'
      }, {
        id: 1,
        name: '客厅电视柜'
      }, {
        id: 2,
        name: '西厨岛台柜'
      }, {
        id: 3,
        name: '西厨橱柜'
      }, {
        id: 4,
        name: '中厨橱柜（左）'
      }, {
        id: 5,
        name: '中厨橱柜（右）'
      }, {
        id: 6,
        name: '储物柜'
      }, {
        id: 7,
        name: '客卫镜柜'
      }, {
        id: 8,
        name: '走道储物柜'
      }, {
        id: 9,
        name: '主卫镜柜'
      }]
    ],
    curId:0,
    mediaList:[],
  },
  cabinetChange(e) {
    let that = this;
    let mediaList = that.data.mediaList;
    mediaList[0] = that.data.baseUrl+"images/cabinetimgs/big"+that.data.cabinetIndex+"-"+e.detail.value+".png";
    that.setData({
      mediaList:mediaList,
      curId:e.detail.value,
      cabinet: that.data.cabinetList[that.data.cabinetIndex][e.detail.value].name,
    })
  },
 // 预览图片
 previewImage(e) {
  let {
    sources,
    index
  } = e.currentTarget.dataset
  wx.previewImage({
    urls:sources,
    current: index
  })
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let that = this;
    let cabinetIndex = parseInt(options.id);
    let mediaList = that.data.mediaList;
    mediaList[0] = that.data.baseUrl+"images/cabinetimgs/big"+that.data.cabinetIndex+"-0.png";
    that.setData({
      mediaList:mediaList,
      cabinetIndex:cabinetIndex
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    var that = this;
    return {
      title: "麓悦江城·麓溪半岛中区收纳柜体图识",
      path: '/pages/cabinetImgs/index',
      imageUrl: 'https://small.andwind.cc/ly_small_service/images/cabinetimgs/share.jpg',
      success: function (res) {

      },
      fail: function (res) {

      }
    }
  },
  // 分享朋友圈
  onShareTimeline() {
    var that = this;
    return {
      title: "麓悦江城·麓溪半岛中区收纳柜体图识",
      imageUrl: 'https://small.andwind.cc/ly_small_service/images/cabinetimgs/share.jpg',
      success: function (res) {

      },
      fail: function (res) {

      }
    }
  }
})